$(function () {
    //Theme Switcher
    $('body').append('<div id="switcher"class=""><div class="toggle-btn"><img src="/image/theme.png" alt="theme"></div><div class="content"><div class="inner"><label>选择主题</label><br><div class="color-container"><span data-skin="" style="background:#f8f8f8;"></span><span data-skin="skin-blue" style="background:#2494F2;"></span><span data-skin="skin-green" style="background:#2ecc71;"></span><span data-skin="skin-red" style="background:#e74c3c;"></span><span data-skin="skin-purple" style="background:#9b59b6;"></span><span data-skin="skin-dark" style="background:#34495e;"></span></div></div></div></div>');

    $('#switcher .toggle-btn').on('click', function () {
        "use strict";
        $('#switcher').toggleClass('open');
    });

    $('span[data-skin]').on('click', function () {
        "use strict";
        var obj = $(this);
        $('body').removeClass(function (index, className) {
            return (className.match (/(^|\s)skin-\S+/g) || []).join(' ');
        }).addClass(obj.data('skin'));
    })

    $('#login-out').click(function () {
        var keys = document.cookie.match(/[^ =;]+(?=\=)/g);
        if (keys) {
            for (var i = keys.length; i--;) {
                document.cookie = keys[i] + '=0;path=/;expires=' + new Date(0).toUTCString();
            }
        }
        location.reload();
    });
});